#ifndef _CRANE_LCD_SPI_NOC_H_
#define _CRANE_LCD_SPI_NOC_H_

#ifdef __cplusplus
extern "C" {
#endif
#include "lv_drv_conf.h"
#if LCD_GENERIC_SPI
#include <stdint.h>
#include "../common/spi_arch.h"

#define SPI_TX_SIZE      512
#define SPI_TX_DCX_BIT   64

typedef int (*spi_read_t)(uint8_t *buf, int bits, bool cont, xfer_mode_t mode);
typedef int (*spi_write_t)(int dc, uint8_t *buf, int bits, bool cont, xfer_mode_t mode);

typedef enum {
  INTERFACE_PROTOCOL_SPI_3_LINE = 3,
  INTERFACE_PROTOCOL_SPI_4_LINE = 4,
} interface_prorocol_t;

struct lcd_spi_info {
  spi_bus_t dev;
  spi_clk_t wclk;
  spi_clk_t rclk;
  spi_mode_t spi_mode;
  interface_prorocol_t protocol;
  int dc_pin;
  int cs_pin;
  const uint32_t *mfp;
  spi_read_t spi_read;
  spi_write_t spi_write;
};

int lcd_spi_init(struct lcd_spi_info *info);
int lcd_spi_write_cmd(uint32_t cmd, int bits);
int lcd_spi_write_data(uint32_t data, int bits);
int lcd_spi_read_data(uint32_t cmd, int cmd_bits, uint32_t *data, int data_bits, uint8_t read_gram);
int lcd_spi_write_fb(uint8_t *buf, int byte, xfer_mode_t mode);
int lcd_spi_read8(uint8_t cmd, uint8_t *data);
int lcd_spi_read24(uint8_t cmd, uint32_t *data);
int lcd_spi_read32(uint8_t cmd, uint32_t *data);
#endif /* LCD_GENERIC_SPI */

#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
